#ifndef OUTPUT_HEX_CPP
#define OUTPUT_HEX_CPP

#include <string>
#include <vector>
#include <bitset>
#include <stdint.h>

char Bin2HexChar(uint8_t x)
{
    switch (x)
    {
        case 0x0: return '0'; break;
        case 0x1: return '1'; break;
        case 0x2: return '2'; break;
        case 0x3: return '3'; break;
        case 0x4: return '4'; break;
        case 0x5: return '5'; break;
        case 0x6: return '6'; break;
        case 0x7: return '7'; break;
        case 0x8: return '8'; break;
        case 0x9: return '9'; break;
        case 0xA: return 'A'; break;
        case 0xB: return 'B'; break;
        case 0xC: return 'C'; break;
        case 0xD: return 'D'; break;
        case 0xE: return 'E'; break;
        case 0xF: return 'F'; break;
        default: break;
    }
    return '0';
}

std::string Bin2Hex(std::string Bdata)
{
    std::string outputStr;
    for(char i : Bdata)
    {
        outputStr.push_back(Bin2HexChar((i & 0xF0)>>4));
        outputStr.push_back(Bin2HexChar(i & 0x0F));
        outputStr.push_back(' ');
    }
    return outputStr;
}

#endif